package router

import (
	"gdshop-admin-go-api/app/controllers/shop"
	"gdshop-admin-go-api/app/request/BaseReq"
	"github.com/gogf/gf/net/ghttp"
)

func regShop(s *ghttp.Server, versionName, defaultVersionName string) {
	// 路由前缀
	routerPrefix := "/shop"
	// 注册 店铺
	s.Group(routerPrefix+"/store", func(group *ghttp.RouterGroup) {
		group.Middleware(MiddlewareIsMemberLogin)

		c := shop.NewStoreController(&BaseReq.I{
			TableName:          "store",
			InfoIgnoreProperty: "delete_at", // info 时过滤
		})
		controllerMaps := map[string]interface{}{
			"1.0.0": c,
		}
		// 权限判断
		group.Middleware(MiddlewareMemberPermissions)
		// 注册基础方法
		regBase([]string{
			"add",
			"delete",
			"update",
			"info",
			"list",
			"page",
		}, group, controllerMaps, versionName, defaultVersionName)
	})

	// 注册 商品
	s.Group(routerPrefix+"/goods", func(group *ghttp.RouterGroup) {
		group.Middleware(MiddlewareIsMemberLogin)

		c := shop.NewGoodsController(&BaseReq.I{
			TableName:          "goods",
			InfoIgnoreProperty: "delete_at", // info 时过滤
		})
		controllerMaps := map[string]interface{}{
			"1.0.0": c,
		}
		// 权限判断
		group.Middleware(MiddlewareMemberPermissions)
		// 注册基础方法
		regBase([]string{
			"add",
			"delete",
			"update",
			"info",
			"list",
			"page",
		}, group, controllerMaps, versionName, defaultVersionName)
	})

	// 注册 订单
	s.Group(routerPrefix+"/order", func(group *ghttp.RouterGroup) {
		group.Middleware(MiddlewareIsMemberLogin)

		c := shop.NewGoodsController(&BaseReq.I{
			TableName:          "order",
			InfoIgnoreProperty: "delete_at", // info 时过滤
		})
		controllerMaps := map[string]interface{}{
			"1.0.0": c,
		}
		// 权限判断
		group.Middleware(MiddlewareMemberPermissions)
		// 注册基础方法
		regBase([]string{
			"delete",
			"update",
			"info",
			"list",
			"page",
		}, group, controllerMaps, versionName, defaultVersionName)
	})
}
